package com.jifen.agent.controller;

import com.jifen.agent.entity.SmarketAdd;
import com.jifen.agent.service.AgentService;
import com.jifen.common.CommonResult;
import com.jifen.common.Result;
import com.jifen.mch.entity.Mch;
import com.jifen.mch.entity.MchAdd;
import com.jifen.mch.vo.MchParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/jf/{version}/agent")
public class AgentController {

    @Autowired
    AgentService agentService;

    /**
     * 我的超市
     * @param param
     * @return
     */
    @RequestMapping("/getMySmarket")
    @ResponseBody
    public Result getMyMarket(MchParam param) {
        return CommonResult.createSuccessResult(agentService.getMySmarket(param));
    }

    /**
     * 我的商家
     * @param param
     * @return
     */
    @RequestMapping("/getMyMch")
    @ResponseBody
    public Result getMyMch(MchParam param) {
        return CommonResult.createSuccessResult(agentService.getMyMch(param));
    }

    /**
     * 开商家
     * @param add
     * @return
     */
    @RequestMapping("/addMch")
    @ResponseBody
    public Result addMch(MchAdd add) {
        agentService.addMch(add);
        return CommonResult.createSuccessResult();
    }

    /**
     * 开超市
     * @param add
     * @return
     */
    @RequestMapping("/addSmarket")
    @ResponseBody
    public Result addSmarket(SmarketAdd add) {
        agentService.addSmarket(add);
        return CommonResult.createSuccessResult();
    }

    /**
     * 超市积分明细
     * @param param
     * @return
     */
    @RequestMapping("/getSmarketJifenDetail")
    @ResponseBody
    public Result getSmarketJifenDetail(MchParam param) {
        return CommonResult.createSuccessResult(agentService.getSmarketJifenDetail(param));
    }

    /**
     * 超市账单
     * @param param
     * @return
     */
    @RequestMapping("/getSmarketBill")
    @ResponseBody
    public Result getSmarketBill(MchParam param) {
        return CommonResult.createSuccessResult(agentService.smarketBill(param));
    }

    /**
     * 修改超市信息
     * @param smarket
     * @return
     */
    @RequestMapping("/modifySmarket")
    @ResponseBody
    public Result modifySmarket(SmarketAdd smarket){
        agentService.modifySmarket(smarket);
        return CommonResult.createSuccessResult();
    }
}
